package com.orange.lswidget;

import com.orange.util.LogHelper;

import android.content.ComponentName;
import android.widget.RemoteViews;

public class LSWidgetManager {
	private static final String		TAG							= "LSWidgetManager";

	public static final String		EXTRA_LSWIDGET_TYPE			= "ls_widget_type";

	public static final String		META_DATA_LSWIDGET_PROVIDER	= "android.lswidget.provider";

	public static final String		ACTION_LSWIDGET_UPDATE		= "com.orange.lswdiget.action.LSWIDGET_UPDATE";
	public static final String		ACTION_LSWIDGET_DELETED		= "com.orange.lswdiget.action.LSWIDGET_DELETED";
	public static final String		ACTION_LSWIDGET_DISABLED	= "com.orange.lswdiget.action.LSWIDGET_DISABLED";
	public static final String		ACTION_LSWIDGET_ENABLED		= "com.orange.lswdiget.action.LSWIDGET_ENABLED";

	private static LSWidgetService	sService;
	private static LSWidgetManager	sManager;

	private static Object			sLock						= new Object();

	public static LSWidgetManager getInstance() {
		synchronized (sLock) {
			if (sManager == null) {
				sManager = new LSWidgetManager();
			}
			return sManager;
		}
	}

	public static void updateLSWidgetType(int viewType, RemoteViews views,
			boolean hasContent) {
		synchronized (sLock) {
			if (sService != null) {
				sService.updateLSWidgetType(viewType, views, hasContent);
			}
		}
	}

	public static void updateLSWidgetProvider(ComponentName provider,
			RemoteViews views, boolean hasContent) {
		LogHelper.i("loop", "updateLSWidgetProvider()");
		synchronized (sLock) {
			if (sService != null) {
				sService.updateLSWidgetProvider(provider, views, hasContent);
			}
		}
	}

	public static void setLSWidgetService(LSWidgetService service) {
		sService = service;
	}
}
